import { IsNotEmpty, IsString, IsEnum, IsOptional, IsUUID, IsDate, IsDateString } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import { Priority, ProjectStatus } from '../../../types/enums';
import { Transform } from 'class-transformer';

export class CreateProjectDto {
  @ApiProperty({
    description: '项目名称',
    example: '客户关系管理系统',
  })
  @IsNotEmpty({ message: '项目名称不能为空' })
  @IsString({ message: '项目名称必须是字符串' })
  name: string;

  @ApiProperty({
    description: '项目描述',
    example: '一个用于管理客户关系和销售数据的系统',
  })
  @IsString({ message: '项目描述必须是字符串' })
  @IsOptional()
  description: string;

  @ApiProperty({
    description: '工作区ID',
    example: 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11',
  })
  @IsNotEmpty({ message: '工作区ID不能为空' })
  @IsUUID('4', { message: '工作区ID必须是有效的UUID' })
  workspaceId: string;

  @ApiProperty({
    description: '项目开始日期',
    example: '2023-01-01',
  })
  @IsNotEmpty({ message: '开始日期不能为空' })
  @IsDateString({}, { message: '开始日期必须是有效的日期字符串' })
  startDate: string;

  @ApiProperty({
    description: '项目结束日期',
    example: '2023-12-31',
  })
  @IsNotEmpty({ message: '结束日期不能为空' })
  @IsDateString({}, { message: '结束日期必须是有效的日期字符串' })
  endDate: string;

  @ApiProperty({
    description: '项目状态',
    enum: ProjectStatus,
    default: ProjectStatus.ACTIVE,
    example: ProjectStatus.ACTIVE,
  })
  @IsEnum(ProjectStatus, { message: '项目状态必须是有效的枚举值' })
  @IsOptional()
  status?: ProjectStatus;

  @ApiProperty({
    description: '项目优先级',
    enum: Priority,
    default: Priority.MEDIUM,
    example: Priority.MEDIUM,
  })
  @IsEnum(Priority, { message: '项目优先级必须是有效的枚举值' })
  @IsOptional()
  priority?: Priority;
} 